package svc

import (
	"user/database"
	"user/internal/config"
	"user/internal/dao"
	"user/internal/repo"
)

// ServiceContext   service层 logic所依赖的资源池,例如数据库连接等,依靠这里的serviceContext进行引入
type ServiceContext struct {
	Config   config.Config
	UserRepo repo.UserRepo //user相关操作的接口
}

func NewServiceContext(c config.Config) *ServiceContext {
	connect := database.Connect(c.Mysql.DataSource)
	return &ServiceContext{
		Config:   c,
		UserRepo: dao.NewUserDao(connect),
	}
}
